// 

#include "TopoManager.h"

namespace ai_sim {

Define_Module(TopoManager);

void TopoManager::initialize() {
    // nameControlPlane = par("nameControlPlane").stringValue();
    // nameDataPlane = par("nameDataPlane").stringValue();
    // nameWorker = par("nameWorker").stringValue();

    EV << "Extracting Data plane" << std::endl;
    data_plane_topo.extractByProperty("dataplane");

    EV << "Extracting workers topo" << std::endl;
    workers_topo.extractByProperty("worker");

    EV << "Extracting control plane" << std::endl;
    control_plane_topo.extractByProperty("controlplane");

    cModule * controller_mod = getModuleByPath("^.centralcontroller");
    Topology::Node *_controllernode =
        control_plane_topo.getNodeFor(controller_mod);
    control_plane_topo.calculateWBSSPathsTo(_controllernode);
}

Topology * TopoManager::getDataplaneTopo() {
    return &data_plane_topo;
}
Topology * TopoManager::getWorkersTopo() {
    return &workers_topo;
}
Topology * TopoManager::getControlplaneTopo() {
    return &control_plane_topo;
}

Topology::Node* TopoManager::getNodeinTopo(
    Topology::Node* src_node, Topology* dest_topo) {
    omnetpp::cModule* target = src_node->getModule();
    return dest_topo->getNodeFor(target);
}

}  // namespace ai_sim
